<template>
    <div>
        <span id="left">当前选中{{ num }}项，共{{ sum }}项 </span>
        <button @click="del">清空</button>
    </div>
</template>

<script>
export default {
    props: {
        xxx: {
            String
        }
    },
    components: {

    },
    data() {
        return {

        }
    },
    methods: {
        del() {
            let sum = []
            for (let item in this.xxx) {
                if (this.xxx[item].isdone) {
                    sum.push(item)
                }
            }
            let a = 0
            let b = 0
            for (let i of sum) {
                if (b == 0) {
                    this.xxx.splice(i, 1)
                    b = b + 1
                } else {
                    a = i - b
                    this.xxx.splice(a, 1)
                    b = b + 1
                }


            }
        }

    },
    computed: {
        num () {
            let sum = 0
            for (let item of this.xxx) {
                if (item.isdone) {
                    sum++
                }
            }

            return sum
        },
        sum() {
            return this.xxx.length
        }
    }
}
</script>

<style>
#left {
    margin-right: 30px;
}
</style>